﻿#pragma once
#include "base.h"
#include "Quote.h"

class createDeviceApp : public IFApplication, public IQuoteEvent
{
	FDECLARE_CLASS(createDeviceApp);
public:
	FIDFONT fnt_id;             // 自定义字体ID
	FIDTEXTURE tex_id;
	float sprx, spry;	
	CThostFtdcMdApi *	pMDApi = NULL;
	CQuoteProtocol      protocol;
	int					nRequestID;
	FFString			szInsA;
	FFString			szInsB;
#ifdef _UI
	FUI_System uiSys;
	Quote myWnd;
	tagIns insA;
	tagIns insB;
	
#endif
public:
	virtual bool Create();
	virtual void Destroy();
	virtual void Render();
	virtual bool OnInput(FINPUT_PACKAGE& ipk);	
	virtual void Update();
	
	/*
		Impl
	*/
	virtual void OnFrontConnected() 
	{
		//login
		CThostFtdcReqUserLoginField st;
		sprintf(st.BrokerID, "%s", "9999");
		sprintf(st.UserID, "%s", "123");
		sprintf(st.Password, "%s", "132");
		sprintf(st.BrokerID, "%s", "9999");
		pMDApi->ReqUserLogin(&st, ++nRequestID);
		
	}
	virtual void OnFrontDisconnected(int nReason) 
	{
		
	}
	;
	virtual void OnHeartBeatWarning(int nTimeLapse) 
	{
		
	}
	virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) 
	{
		char* szINSTRUMENT1ID[] = { "SR609", "SR701" };

		pMDApi->SubscribeMarketData(szINSTRUMENT1ID, 2);		
	}
	virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)  
	{
		
	}
	virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData);
	virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) 
	{
		
	}
	
};